package com.fs.jzzn.pojo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang3.StringUtils;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import com.fs.base.pojo.PEntity;
import com.fs.base.utils.ApplicationUtils;
import com.fs.base.utils.ExcelUtils;

/**
 * 物料管理
 * @author ACE
 *
 */
@Entity
@Table(name="p_materiel")
@Data@EqualsAndHashCode(callSuper=false)
@NoArgsConstructor
public class Materiel extends PEntity{
	private String mNo;//物料编码-唯一性
	private String mName;//物料名称
	private String mType;//物料规格
	private String mUnit;//单位
	private String mKind;//物料类别
	private Double money;//参考单价
	private String supplier;//供货单位
	
	
	public static List<Materiel> excelDataFormat(List<List<String>> data) {
		List<Materiel> list = new ArrayList<Materiel>();
		for(List<String> rowData: data){
			Materiel m = excelData2Bean(rowData);
			if(m==null) continue;
			list.add(m);
		}
		return list;
	}
	private static Materiel excelData2Bean(List<String> row) {
		row = ExcelUtils.dataLenFomart(row, 4);
		Materiel p = new Materiel();
		p.setMNo(row.get(0)); 
		p.setMName(row.get(1)); 
		if(StringUtils.isBlank(p.getMNo()) || StringUtils.isBlank(p.getMName())){
			return null;
		}
		p.setMType(row.get(2));
		p.setMUnit(row.get(3));
		p.setCreaterId(ApplicationUtils.userId());
		return p;
	}
}
